Ext.create('Ext.data.Store', {
    storeId: 'wdp_store0',
    fields: ['adCd', 'tw'],
    data: []
});
Ext.create('Ext.data.Store', {
    storeId: 'wdp_store1',
    fields: ["regCd", "townPp", "ruralPp", "llsNum", "slsNum", "pweirA", "pdeirA", "pveirA", "tfgA", "airrA", "fishA", "indEpv", "nindEpv"],
    data: []
});
Ext.create('Ext.data.Store', {
    storeId: 'wdp_store2',
    fields: ["adCd", "dPopGr", "totPopGr", "bhGr", "shGr", "pwirraGr", "pdirraGr", "pvirraGr", "fiaGr", "aiaGr", "fishaGr", "indGr", "nindGr"],
    data: []
});
Ext.create('Ext.data.Store', {
    storeId: 'wdp_store3',
    fields: ["adCd", "dWun", "rWun", "bhWun", "shWun", "pwirWun", "pdirWun", "pvirWun", "fiWun", "aiWun", "fishWun", "indWun", "nindWun"],
    data: []
});
Ext.create('Ext.data.Store', {
    storeId: 'wdp_store4',
    fields: ["adCd", "dWsLr", "crwsR", "crwsLr", "pwirR", "pdirR", "pvirR", "fiR", "aiR","indLr"],
    data: []
});
Ext.create('Ext.data.Store', {
    storeId: 'wdp_store5',
    fields: ["adCd", "month", "pwmCoe", "awmCoe", "iwmCoe", "lmyCoe"],
    data: []
});
Ext.create('Ext.data.Store', {
    storeId: 'wdp_store6',
    fields: ["regCd", "month", "dWat", "uWat", "bhWat", "shWat", "pwirWat", "pdirWat", "pvirWat", "fiWat", "aiWat", "fishWat", "indWat", "nindWat"],
    data: []
});
Ext.create('Ext.data.Store', {
    storeId: 'wdp_store7',
    fields: ["month", "dWat", "uWat", "bhWat", "shWat", "pwirWat", "pdirWat", "pvirWat", "fiWat", "aiWat", "fishWat", "indWat", "nindWat"],
    data: []
});

Ext.define('Admin.view.needWater.waterDemandPrediction.WaterDemandPred', {
    extend: 'Ext.panel.Panel',
    xtype: 'waterDemandPred',
    requires: ['Admin.view.needWater.waterDemandPrediction.WaterDemandPredController'],
    controller: 'waterDemandPredController',
    layout: {
        type: 'hbox',
        align: 'stretch'
    },
    config: {
        calResult: false,
        calBtnClickListener: false
    },
    items: [{
        xtype: 'panel',
        width: 200,
        cls: 'mytab2-panel',
        layout: {
            type: 'vbox',
            align: 'stretch'
        },
        items: [{
            flex: 1,
            xtype: 'grid',
            reference: 'grid0',
            loadMask: true,
            stripeRows: true,
            columnLines: true,
            columns: [{
                header: '行政区',
                dataIndex: 'adCd',
                editor: 'textfield',
                align: 'center',
                style: 'background: #EEEEEE',
                renderer: 'formatAdCdToName',
                flex: 1
            }, {
                header: '申报水量(亿m³)',
                dataIndex: 'tw',
                editor: 'numberfield',
                align: 'right',
                style: 'background: #EEEEEE',
                flex: 2,
                // summaryRenderer: 'sumNeedWater'
            }],
            listeners: {
                rowclick: 'changeArea'
            },
            store: Ext.data.StoreManager.lookup('wdp_store0')
        }, {
            height: 60,
            layout: {
                type: 'vbox',
                align: 'center'
            },
            margin: '20 20 10 20',
            items: [{
                reference: 'twNumText',
                html: '<div style="font-size: 16px;font-weight: bold;color: #FF0000;line-height: 22px;">' +
                '<p>' + (config.RIVER === '02' ? '抚河流域' : (config.RIVER === '03' ? '袁河流域': '')) + '需水总量：</p>' +
                '<p><span class="tw" id="sumNeedWater"></span> 亿立方米</p>' +
                '</div>'
            }]
        }, {
            height: 60,
            items: [{
                tbar: ['->', {
                    xtype: 'button',
                    text: '<span style="font-size: 14px;">需水统计</span>',
                    handler: 'popStatisticsModal'
                }, '-', {
                    xtype: 'button',
                    text: '<span style="font-size: 14px;">保存</span>',
                    handler: 'saveOrUpdate'
                }, '->']
            }]
        }]
    }, {
        flex: 1,
        xtype: 'tabpanel',
        activeItem: 0,
        id: 'wdpTab',
        margin: '0 5 0 10',
        cls: 'mytab2-panel',
        items: [{
            title: '参数设置',
            xtype: 'panel',
            items: [{
                margin: '5 5 0 10',
                layout: {
                    type: 'hbox',
                    align: 'stretch'
                },
                items: [{
                    flex: 1,
                    html: '<div style="padding-top: 17px;">基准年：2015年</div>'
                }, {
                    flex: 1,
                    tbar: ['->', {
                        text: '用水参数设置',
                        handler: 'nwParamsSet'
                    }, '-', {
                            text: '逐月分配系数设置',
                            handler: 'monthParamsSet'
                    }]
                }]
            }, {
                layout: {
                    type: 'accordion',
                    multi: true,
                    animate: true
                },
                items: [{
                    title: '社会经济指标',
                    collapsed: false,
                    cls: 'ext-panel-title',
                    xtype: 'grid',
                    margin: '0 5 5 5',
                    style: 'border: 1px solid #ccc',
                    // scroll: false,
                    reference: 'wdGrid1',
                    loadMask: true,
                    stripeRows: true,
                    columnLines: true,
                    forceFit: true, //表格自适应
                    columns: [{
                        text: '用水单元',
                        dataIndex: 'regCd',
                        align: 'center',
                        width: 150,
                        renderer: 'formatRegCdToName'
                    }, {
                        text: '人口（万人）',
                        columns: [{
                            text: '城市人口',
                            dataIndex: 'townPp',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '农村人口',
                            dataIndex: 'ruralPp',
                            editor: 'numberfield',
                            align: 'right'
                        }]
                    }, {
                        text: '牲畜（万头）',
                        columns: [{
                            text: '大牲畜',
                            dataIndex: 'llsNum',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '小牲畜',
                            dataIndex: 'slsNum',
                            editor: 'numberfield',
                            align: 'right'
                        }]
                    }, {
                        text: '农田有效灌溉面积（万亩）',
                        columns: [{
                            text: '水田',
                            dataIndex: 'pweirA',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '水浇地',
                            dataIndex: 'pdeirA',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '菜地',
                            dataIndex: 'pveirA',
                            editor: 'numberfield',
                            align: 'right'
                        }]
                    }, {
                        text: '林牧鱼用水面积（万亩）',
                        columns: [{
                            text: '林果地',
                            dataIndex: 'tfgA',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '草场',
                            dataIndex: 'airrA',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '鱼塘',
                            dataIndex: 'fishA',
                            editor: 'numberfield',
                            align: 'right'
                        }]
                    }, {
                        text: '工业增加值（万元）',
                        columns: [{
                            text: '火核',
                            dataIndex: 'indEpv',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '非火核',
                            dataIndex: 'nindEpv',
                            editor: 'numberfield',
                            align: 'right'
                        }]
                    }],
                    store: Ext.data.StoreManager.lookup('wdp_store1'),
                    plugins: {
                        ptype: 'cellediting',
                        clicksToEdit: 1
                    },
                    listeners: {
                        edit: 'clacDeatilNeedWater'
                    }
                }, {
                    title: '社会经济发展参数',
                    collapsed: false,
                    cls: 'ext-panel-title',
                    xtype: 'grid',
                    margin: '0 5 5 5',
                    // height: 250,
                    style: 'border: 1px solid #ccc',
                    reference: 'wdGrid2',
                    loadMask: true,
                    stripeRows: true,
                    columnLines: true,
                    forceFit: true, //表格自适应
                    columns: [{
                        text: '用水区域', dataIndex: 'adCd', align: 'center', width: 150,
                        renderer: 'formatAdCdToName'
                    }, {
                        text: '人口增长率（%）',
                        columns: [{
                            text: '城市', dataIndex: 'dPopGr', editor: 'numberfield', align: 'right'
                        }, {
                            text: '总人口', dataIndex: 'totPopGr', editor: 'numberfield', align: 'right'
                        }]
                    }, {
                        text: '牲畜增长率（%）',
                        columns: [{
                            text: '大牲畜', dataIndex: 'bhGr', editor: 'numberfield', align: 'right'
                        }, {
                            text: '小牲畜', dataIndex: 'shGr', editor: 'numberfield', align: 'right'
                        }]
                    }, {
                        text: '农田灌溉面积增长率（%）',
                        columns: [{
                            text: '水田', dataIndex: 'pwirraGr', editor: 'numberfield', align: 'right'
                        }, {
                            text: '水浇地', dataIndex: 'pdirraGr', editor: 'numberfield', align: 'right'
                        }, {
                            text: '菜地', dataIndex: 'pvirraGr', editor: 'numberfield', align: 'right'
                        }]
                    }, {
                        text: '林牧鱼业增长率（%）',
                        columns: [{
                            text: '林果地', dataIndex: 'fiaGr', editor: 'numberfield', align: 'right'
                        }, {
                            text: '草场', dataIndex: 'aiaGr', editor: 'numberfield', align: 'right'
                        }, {
                            text: '鱼塘', dataIndex: 'fishaGr', editor: 'numberfield', align: 'right'
                        }]
                    }, {
                        text: '工业增加值增长率（%）',
                        columns: [{
                            text: '火核', dataIndex: 'indGr', editor: 'numberfield', align: 'right'
                        }, {
                            text: '非火核', dataIndex: 'nindGr', editor: 'numberfield', align: 'right'
                        }]
                    }],
                    store: Ext.data.StoreManager.lookup('wdp_store2'),
                    plugins: {
                        ptype: 'cellediting',
                        clicksToEdit: 1
                    },
                    listeners: {
                        edit: 'clacDeatilNeedWater'
                    }
                }, {
                    title: '用水定额',
                    collapsed: false,
                    cls: 'ext-panel-title',
                    xtype: 'grid',
                    margin: '0 5 5 5',
                    style: 'border: 1px solid #ccc',
                    reference: 'wdGrid3',
                    loadMask: true,
                    stripeRows: true,
                    columnLines: true,
                    forceFit: true, //表格自适应
                    columns: [{
                        text: '用水区域',
                        dataIndex: 'adCd',
                        align: 'center',
                        width: 150,
                        renderer: 'formatAdCdToName'
                    }, {
                        text: '生活（L）',
                        columns: [{
                            text: '城市',
                            dataIndex: 'dWun',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '农村',
                            dataIndex: 'rWun',
                            editor: 'numberfield',
                            align: 'right'
                        }]
                    }, {
                        text: '牲畜头均日用水量（L）',
                        columns: [{
                            text: '大牲畜',
                            dataIndex: 'bhWun',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '小牲畜',
                            dataIndex: 'shWun',
                            editor: 'numberfield',
                            align: 'right'
                        }]
                    }, {
                        text: '农田灌溉亩均用水量（m³）',
                        columns: [{
                            text: '水田',
                            dataIndex: 'pwirWun',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '水浇地',
                            dataIndex: 'pdirWun',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '菜地',
                            dataIndex: 'pvirWun',
                            editor: 'numberfield',
                            align: 'right'
                        }]
                    }, {
                        text: '林牧鱼业亩均用水量（m³）',
                        columns: [{
                            text: '林果地',
                            dataIndex: 'fiWun',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '草场',
                            dataIndex: 'aiWun',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '鱼塘',
                            dataIndex: 'fishWun',
                            editor: 'numberfield',
                            align: 'right'
                        }]
                    }, {
                        text: '单位工业增加值用水量（m3/万元）',
                        columns: [{
                            text: '火核',
                            dataIndex: 'indWun',
                            editor: 'numberfield',
                            align: 'right'
                        }, {
                            text: '非火核',
                            dataIndex: 'nindWun',
                            editor: 'numberfield',
                            align: 'right'
                        }]
                    }],
                    store: Ext.data.StoreManager.lookup('wdp_store3'),
                    plugins: {
                        ptype: 'cellediting',
                        clicksToEdit: 1
                    },
                    listeners: {
                        edit: 'clacDeatilNeedWater'
                    }
                }]
            }],
            listeners: {
                // activate: 'activeDetailTab'
            }
        }, {
            title: '详细结果',
            id: 'wd-tab2-content',
            layout: {
                type: 'vbox',
                align: 'stretch'
            },
            items: [{
                height: 180,
                xtype: 'grid',
                margin: 10,
                style: 'border: 1px solid #ccc',
                reference: 'wdGrid5',
                loadMask: true,
                stripeRows: true,
                columnLines: true,
                forceFit: true, //表格自适应
                columns: [{
                    text: '用水区域',
                    dataIndex: 'regCd',
                    align: 'center',
                    width: 150,
                    renderer: 'formatRegCdToName'
                }, {
                    text: '生活需水量（万m³）',
                    columns: [{
                        text: '城市居民',
                        dataIndex: 'dWat',
                        editor: 'numberfield',
                        align: 'right'
                    }, {
                        text: '农村居民',
                        dataIndex: 'uWat',
                        editor: 'numberfield',
                        align: 'right'
                    }, {
                        text: '大牲畜',
                        dataIndex: 'bhWat',
                        editor: 'numberfield',
                        align: 'right'
                    }, {
                        text: '小牲畜',
                        dataIndex: 'shWat',
                        editor: 'numberfield',
                        align: 'right'
                    }]
                }, {
                    text: '农业需水量（万m³）',
                    columns: [{
                        text: '水田',
                        dataIndex: 'pwirWat',
                        editor: 'numberfield',
                        align: 'right'
                    }, {
                        text: '水浇地',
                        dataIndex: 'pdirWat',
                        editor: 'numberfield',
                        align: 'right'
                    }, {
                        text: '菜田',
                        dataIndex: 'pvirWat',
                        editor: 'numberfield',
                        align: 'right'
                    }, {
                        text: '林果地',
                        dataIndex: 'fiWat',
                        editor: 'numberfield',
                        align: 'right'
                    }, {
                        text: '草场',
                        dataIndex: 'aiWat',
                        editor: 'numberfield',
                        align: 'right'
                    }, {
                        text: '鱼塘',
                        dataIndex: 'fishWat',
                        editor: 'numberfield',
                        align: 'right'
                    }]
                }, {
                    text: '工业需水量（万m³）',
                    columns: [{
                        text: '火核',
                        dataIndex: 'indWat',
                        editor: 'numberfield',
                        align: 'right'
                    }, {
                        text: '非火核',
                        dataIndex: 'nindWat',
                        editor: 'numberfield',
                        align: 'right'
                    }]
                }],
                store: Ext.data.StoreManager.lookup('wdp_store6'),
                plugins: {
                    ptype: 'cellediting',
                    clicksToEdit: 1
                }
            }, {
                flex: 1,
                xtype: 'panel',
                id: 'wd-tab2-chart-panel',
                tbar: [{
                    xtype: "combo",
                    maxWidth: 220,
                    // width: '15%',
                    labelWidth: 35,
                    fieldLabel: "",
                    // labelWidth: 85,
                    id: "waterTypeSelect",
                    valueField: 'value', //值字段
                    displayField: 'text', //显示字段
                    value: '1', //默认值,要设置为提交给后台的值，不要设置为显示文本
                    emptyText: '请选择', //提示信息
                    readOnly: false, //只读，为true时不能编辑不能点击
                    selectOnFocus: true,
                    editable: false,
                    store: {
                        fields: ['value', 'text'],
                        data: [
                            ['1', '用水区域'],
                            ['2', '用水类型']
                        ]
                    },
                    listeners: {
                        'select': 'selectChart'
                    }
                }],
                listeners: {
                    resize: 'changeWdTab2Chart'
                }
            }],
            listeners: {
                // activate: 'activeDetailTab'
            }
        }, {
            title: '逐月需水',
            layout: {
                type: 'vbox',
                align: 'stretch'
            },
            items: [{
                flex: 1,
                xtype: 'grid',
                margin: 10,
                reference: 'wdTab3Grid1',
                loadMask: true,
                stripeRows: true,
                columnLines: true,
                forceFit: true, //表格自适应
                style: 'border: 1px solid #ccc',
                columns: [{
                    text: '月份',
                    dataIndex: 'month',
                    align: 'center',
                    width: 150
                }, {
                    text: '生活（万m³）',
                    columns: [{
                        text: '城镇',
                        dataIndex: 'dWat',
                        align: 'right',
                        xtype: "numbercolumn", 
                        format: '0.0'
                    }, {
                        text: '农村',
                        dataIndex: 'uWat',
                        align: 'right',
                        xtype: "numbercolumn", 
                        format: '0.0'
                    }, {
                        text: '大牲畜',
                        dataIndex: 'bhWat',
                        align: 'right',
                        xtype: "numbercolumn", 
                        format: '0.0'
                    }, {
                        text: '小牲畜',
                        dataIndex: 'shWat',
                        align: 'right',
                        xtype: "numbercolumn", 
                        format: '0.0'
                    }]
                }, {
                    text: '农业（万m³）',
                    columns: [{
                        text: '水田',
                        dataIndex: 'pwirWat',
                        align: 'right',
                        xtype: "numbercolumn", 
                        format: '0.0'
                    }, {
                        text: '水浇地',
                        dataIndex: 'pdirWat',
                        align: 'right',
                        xtype: "numbercolumn", 
                        format: '0.0'
                    }, {
                        text: '菜田',
                        dataIndex: 'pvirWat',
                        align: 'right',
                        xtype: "numbercolumn", 
                        format: '0.0'
                    }]
                }, {
                    text: '林牧渔（万m³）',
                    columns: [{
                        text: '林果地',
                        dataIndex: 'fiWat',
                        align: 'right',
                        xtype: "numbercolumn", 
                        format: '0.0'
                    }, {
                        text: '草场',
                        dataIndex: 'aiWat',
                        align: 'right',
                        xtype: "numbercolumn", 
                        format: '0.0'
                    }, {
                        text: '鱼塘',
                        dataIndex: 'fishWat',
                        align: 'right',
                        xtype: "numbercolumn", 
                        format: '0.0'
                    }]
                }, {
                    text: '工业（万m³）',
                    columns: [{
                        text: '火核',
                        dataIndex: 'indWat',
                        align: 'right',
                        xtype: "numbercolumn", 
                        format: '0.0'
                    }, {
                        text: '非火核',
                        dataIndex: 'nindWat',
                        align: 'right',
                        xtype: "numbercolumn", 
                        format: '0.0'
                    }]
                }],
                store: Ext.data.StoreManager.lookup('wdp_store7')
            }, {
                flex: 1,
                layout: {
                    type: 'hbox',
                    align: 'stretch'
                },
                items: [{
                    flex: 1,
                    xtype: 'panel',
                    reference: 'wdTab3Chart1',
                    listeners: {
                        'resize': 'buildTab3Chart'
                    }
                }]
            }]
        }]
    }],
    listeners: {
        show: 'afterRenderInit'
        // show: function () {
        //     console.log('1111111111111111');
        //     // $('#needWaterCal').off('click');
        //     // $('#needWaterCal').on('click', function () {
        //     //     Ext.getCmp('wdpTab').setActiveItem(1);
        //     //     // me.getView().setCalResult(true);
        //     // });
        // }
    }
});
